package cn.lu.train.map;

import android.view.View;

import com.baidu.mapapi.map.BaiduMap;
import com.baidu.mapapi.map.BitmapDescriptor;
import com.baidu.mapapi.map.BitmapDescriptorFactory;

import java.util.ArrayList;
import java.util.List;

public class MyDrivingRouteOverlay extends DrivingRouteOverlay {
    private boolean useDefaultIcon = false;//自定义图标
    private View startView;
    private View endView;
    private ArrayList<View> passView;

    public MyDrivingRouteOverlay(BaiduMap baiduMap) {
        super(baiduMap);
    }

    public MyDrivingRouteOverlay(BaiduMap baiduMap,View startView,View endView,ArrayList<View> passView) {
        super(baiduMap);
        useDefaultIcon = true;
        this.startView=startView;
        this.endView=endView;
        this.passView=passView;
    }

    @Override
    public BitmapDescriptor getStartMarker() {
        if (useDefaultIcon) {
            if (startView==null) {
                return null;
            }
            return BitmapDescriptorFactory.fromView(startView);
        }
        return null;
    }

    @Override
    public List<BitmapDescriptor> getCustomTextureList() {
        // TODO Auto-generated method stub
        if (useDefaultIcon) {
            if (passView==null) {
                return null;
            }
            ArrayList<BitmapDescriptor> list = new ArrayList<>();
            for (int i = 0; i < passView.size(); i++) {
                list.add(BitmapDescriptorFactory.fromView(passView.get(i)));
            }
            return list;
        }
        return null;
    }

    @Override
    public int getLineColor() {
        // TODO Auto-generated method stub
        //覆写此方法以改变默认绘制颜色
        //Returns:
        //线颜色
        return super.getLineColor();
    }
    @Override
    public BitmapDescriptor getTerminalMarker() {
        if (useDefaultIcon) {
            if (endView==null) {
                return null;
            }
            return BitmapDescriptorFactory.fromView(endView);
        }
        return null;
    }

    @Override
    public boolean onRouteNodeClick(int i) {
        // TODO Auto-generated method stub
        System.out.println(""+i);
        return true;
    }
}
